﻿using System;
using System.Globalization;
using System.Windows.Data;
using RadarMonitor;

namespace RadarMonitor.Converter
{
    class ResultCodeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var code  = (RadarMonitorResultCode)value;
            string resultStr = "未知";
            switch (code){
                case RadarMonitorResultCode.Success:
                    resultStr = "正常";
                    break;
                case RadarMonitorResultCode.FTPAcesssFailed:
                    resultStr = "访问FTP失败";
                    break;
                case RadarMonitorResultCode.FTPFileUploadFailed:
                    resultStr = "文件上传超时";
                    break;
                case RadarMonitorResultCode.FTPFileNotExist:
                    resultStr = "FTP文件夹中无符合命名格式的文件";
                    break;

                case RadarMonitorResultCode.CIMISSAcesssFailed:
                    resultStr = "访问CIMISS失败";
                    break;
                case RadarMonitorResultCode.CIMISSFileUploadFailed:
                    resultStr = "未及时上传文件至CIMISS";
                    break;

                case RadarMonitorResultCode.PingFailed:
                    resultStr = "Ping失败";    
                    break;

                case RadarMonitorResultCode.RDA_CommnunicationFailed:
                    resultStr = "与RDA通信失败";
                    break;
                case RadarMonitorResultCode.RDA_Alram:
                    resultStr = "RDA 报警";
                    break;
                case RadarMonitorResultCode.Monitor_Error:
                    resultStr = "监控系统故障";
                    break;
                case RadarMonitorResultCode.DingDingSendError:
                    resultStr = "发送钉钉通知失败";
                    break;
                default:
                    break;
            }

            return resultStr;
            
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    
    }

    class SourceCodeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var code = (RadarMonitorSource)value;
            string resultStr = "未知";
            switch (code)
            {
                case RadarMonitorSource.BaseFTP:
                    resultStr = "基数据(FTP源)";
                    break;
                case RadarMonitorSource.CIMISS:
                    resultStr = "基数据(CIMISS源)";
                    break;
                case RadarMonitorSource.ProductsMonitor:
                    resultStr = "雷达产品(FTP)";
                    break;
                case RadarMonitorSource.NetPing:
                    resultStr = "雷达站网络监控";
                    break;

                case RadarMonitorSource.RDA_STATUS:
                    resultStr = "RDA状态文件";
                    break;

                case RadarMonitorSource.App:
                    resultStr = "监控软件";
                    break;
                default:
                    break;
            }

            return resultStr;

        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

    }
}
